import { IsNotEmpty, IsString, IsEnum, IsOptional } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { PermissionGroup } from '../../../entities/permission.entity';

export class CreatePermissionDto {
  @ApiProperty({ description: '权限名称', example: '系统权限查看' })
  @IsNotEmpty({ message: '权限名称不能为空' })
  @IsString({ message: '权限名称必须是字符串' })
  name: string;

  @ApiProperty({ description: '权限代码', example: 'system:permission:read' })
  @IsNotEmpty({ message: '权限代码不能为空' })
  @IsString({ message: '权限代码必须是字符串' })
  code: string;

  @ApiProperty({ 
    description: '权限分组', 
    enum: PermissionGroup, 
    example: PermissionGroup.SYSTEM 
  })
  @IsNotEmpty({ message: '权限分组不能为空' })
  @IsEnum(PermissionGroup, { message: '无效的权限分组' })
  group: PermissionGroup;

  @ApiPropertyOptional({ description: '权限描述', example: '查看系统权限列表' })
  @IsOptional()
  @IsString({ message: '权限描述必须是字符串' })
  description?: string;
} 